<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/template.xhtml">

<ui:define name="body">

    <a:form id="vendaFinanceiroForm">
    
    
        <rich:panel style="background-color: #FFFFFF;">
            <f:facet name="header">Comprador</f:facet>

        

				<fieldset id="child-dadosPessoais">
				<legend>Dados Pessoais</legend>
				
		            <ui:repeat value="#{ConsultaVenda.venda.clientesPF}" var="_pf">
		            
						<ul>
						<h:panelGrid width="100%" columns="4" border="0">
						
							<h:panelGroup>
								<h:outputText value="Nome " styleClass="name2" />
								<h:outputText value="#{_pf.nome}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="CPF " styleClass="name2" />
								<h:outputText value="#{_pf.cpf}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="RG " styleClass="name2" />
								<h:outputText value="#{_pf.rg}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Sexo: " styleClass="name2" />
								<h:outputText value="#{_pf.sexo}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="E-Mail: " styleClass="name2" />
								<h:outputText value="#{_pf.email}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Fone 01: " styleClass="name2" />
								<h:outputText value="#{_pf.fone1}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Fone 02: " styleClass="name2" />
								<h:outputText value="#{_pf.fone2}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Fone 03: " styleClass="name2" />
								<h:outputText value="#{_pf.fone3}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Endereco:" styleClass="name2" />
								<h:outputText value="#{_pf.logradouro}, #{_pf.numero} #{_pf.complemento } #{_pf.bairro}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="CEP" styleClass="name2" />
								<h:outputText value="#{_pf.cep}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Cidade" styleClass="name2" />
								<h:outputText value="#{_pf.cidade.nome}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Estado" styleClass="name2" />
								<h:outputText value="#{_pf.cidade.siglaUf}" styleClass="value2" />
							</h:panelGroup>
							
							
							
						</h:panelGrid>
						</ul>
						
					</ui:repeat>
					
		            <ui:repeat value="#{ConsultaVenda.venda.clientesPJ}" var="_pj">
		            
						<ul>
						<h:panelGrid width="100%" columns="4" border="0">
						
							<h:panelGroup>
								<h:outputText value="CNPJ" styleClass="name2" />
								<h:outputText value="#{_pj.cnpj}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Razao Social" styleClass="name2" />
								<h:outputText value="#{_pj.razaoSocial}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Nome Fantasia" styleClass="name2" />
								<h:outputText value="#{_pj.nomeFantasia}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Responsavel Legal" styleClass="name2" />
								<h:outputText value="#{_pj.cpfResponsavelLegal} - #{_pj.nomeResponsavelLegal}" styleClass="value2" />
							</h:panelGroup>
							
							
							<h:panelGroup>
								<h:outputText value="E-Mail: " styleClass="name2" />
								<h:outputText value="#{_pj.email}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Fone 01: " styleClass="name2" />
								<h:outputText value="#{_pj.fone1}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Fone 02: " styleClass="name2" />
								<h:outputText value="#{_pj.fone2}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Fone 03: " styleClass="name2" />
								<h:outputText value="#{_pj.fone3}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Endereco:" styleClass="name2" />
								<h:outputText value="#{_pj.logradouro}, #{_pf.numero} #{_pf.complemento } #{_pf.bairro}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="CEP" styleClass="name2" />
								<h:outputText value="#{_pj.cep}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Cidade" styleClass="name2" />
								<h:outputText value="#{_pj.cidade.nome}" styleClass="value2" />
							</h:panelGroup>
							
							<h:panelGroup>
								<h:outputText value="Estado" styleClass="name2" />
								<h:outputText value="#{_pj.cidade.siglaUf}" styleClass="value2" />
							</h:panelGroup>
							
							
							
						</h:panelGrid>
						</ul>
						
					</ui:repeat>
				</fieldset>
		</rich:panel>
		
        <rich:panel style="background-color: #FFFFFF;">
            <f:facet name="header">Lote</f:facet>
            
				<fieldset id="child-lotes">
				<legend>Lotes</legend>
				<ul>
            
		            <ui:repeat value="#{ConsultaVenda.venda.lotes}" var="_lote">
						<h:panelGrid width="100%" columns="10" border="0">
									<h:outputText value="Lote: " styleClass="name3" style="width: 30px; float: right;" />
									<h:outputText value="#{_lote.codigoLote}" styleClass="value2" />
									
									<h:outputText value="Quadra: " styleClass="name3" style="width: 50px; float: right;"/>
									<h:outputText value="#{_lote.quadra.codigo}" styleClass="value2" />
									
									<h:outputText value="Situacao Financeiro: " styleClass="name3" style="width: 120px; float: right;"/>
									<h:outputText value="#{_lote.statusLoteFinanceiro}" styleClass="value2" />
									
									<h:outputText value="Situacao Venda: " styleClass="name3" style="width: 100px; float: right;"/>
									<h:outputText value="#{_lote.statusLoteVenda}" styleClass="value2" />
									
									<h:outputText value="Situacao Legal: " styleClass="name3" style="width: 100px; float: right;"/>
									<h:outputText value="#{_lote.statusLoteLegal}" styleClass="value2" />
									
						</h:panelGrid>
		            </ui:repeat>
		            
	            </ul>
	            </fieldset>
				
		</rich:panel>

        <rich:panel style="background-color: #FFFFFF;">
            <f:facet name="header">Financeiro</f:facet>

				
				
				<fieldset id="child-Finanproprio">
				<legend>Parcelas Caixa Ecomonica</legend>
				
				<div class="dialog">
					<rich:dataTable id="parcelasCEFDataTable" value="#{ConsultaVenda.parcelasFinancimentoCEF}" var="_parcela" styleClass="center-text" >
					
						<h:column>
							<f:facet name="header">Parcela</f:facet>
	                    	#{_parcela.parcela}a
						</h:column>
						
						<h:column>
							<f:facet name="header">Vencimento</f:facet>
	                    	<h:outputFormat value="{0,date,dd/MM/yyyy}"  >
	                    		<f:param value="#{_parcela.dataVencimento}" />
	                    	</h:outputFormat> 
						</h:column>
						
						<h:column>
							<f:facet name="header">Valor</f:facet>
	                    	<h:outputFormat value="{0,number,R$ #,###.00}"  >
	                    		<f:param value="#{_parcela.valor}" />
	                    	</h:outputFormat> 
						</h:column>
						
						<h:column>
							<f:facet name="header">Situacao</f:facet>
	                    	#{_parcela.statusParcela}
						</h:column>
						
						<h:column>
							<f:facet name="header">Acoes</f:facet>
							
							<h:outputLink value="#" id="linkQuitaParcela" rendered="#{_parcela.statusParcela == 'PENDENTE'}">
							        Quitar 
							        <a:support event="onclick" action="#{ConsultaVenda.setParcelaFinancimentoCEFSelecionada(_parcela)}" reRender="parcelaID2,vencimentoID2,situacaoID2,valorAtualID2" />
							        <rich:componentControl for="panelModalQuitaParcela" attachTo="linkQuitaParcela" operation="show" event="onmouseup" />
						    </h:outputLink>
						    
							<h:outputLink value="#" id="link"  rendered="#{_parcela.statusParcela == 'PENDENTE'}">
							        Ajustar Valor 
							        <a:support event="onclick" action="#{ConsultaVenda.setParcelaFinancimentoCEFSelecionada(_parcela)}"  reRender="parcelaID,vencimentoID,situacaoID,valorAtualID" />
							        <rich:componentControl for="panelModalAjusteParcela" attachTo="link" operation="show" event="onmouseup" />
						    </h:outputLink>
						</h:column>
					
					</rich:dataTable>
					
				</div>

				</fieldset>
		</rich:panel>
    </a:form>
		
	    <!-- Modal de ajuste de parcela -->	
	    <rich:modalPanel id="panelModalAjusteParcela" width="360" height="270">
	        <f:facet name="header">
	            <h:panelGroup>
	                <h:outputText value="Ajuste de Valor"></h:outputText>
	            </h:panelGroup>
	        </f:facet>
	        <f:facet name="controls">
	            <h:panelGroup>
	                <h:graphicImage value="/img/close.png" styleClass="hidelink" id="hidelink"/>
	                <rich:componentControl for="panelModalAjusteParcela" attachTo="hidelink" operation="hide" event="onclick"/>
	            </h:panelGroup>
	        </f:facet>
	        
	        <s:div id="mensagemPanelModalAjusteParcela">
		        <h:messages />
	        </s:div>
	        <a:form>
						<h:panelGrid width="100%" columns="2" border="0" >
						
							<h:outputText value="Parcela" styleClass="name2-1" />
							<h:outputText id="parcelaID" value="#{ConsultaVenda.parcelaFinancimentoCEFSelecionada.parcela}a" />
							
							<h:outputText value="Vencimento" styleClass="name2-1" />
							<h:outputText id="vencimentoID" value="#{ConsultaVenda.parcelaFinancimentoCEFSelecionada.dataVencimento}" />
							
							<h:outputText value="Situacao" styleClass="name2-1" />
							<h:outputText id="situacaoID" value="#{ConsultaVenda.parcelaFinancimentoCEFSelecionada.statusParcela}" />
							
							<h:outputText value="Valor Atual" styleClass="name2-1" />
							<h:outputText id="valorAtualID" value="#{ConsultaVenda.parcelaFinancimentoCEFSelecionada.valor}" />
							
							<h:outputText value="Novo valor" styleClass="name2-1" />
							<h:inputText id="novoValorID" value="#{ConsultaVenda.novoValor}" />
							
							<h:outputText value="Atualizar posteriores?" styleClass="name2" />
							<h:selectOneMenu value="#{ConsultaVenda.atualizarPosteriores}" >
								<f:selectItem itemLabel="SIM" itemValue="true"/>
								<f:selectItem itemLabel="NAO" itemValue="false"/>
							</h:selectOneMenu>


						</h:panelGrid>
						
						<rich:spacer />
						<h:panelGrid width="100%" columns="2" border="0" style="align: center" >
							
							<a:commandButton id="btConfirmaAjusteParcelaCEFModal" action="#{ConsultaVenda.ajustaValorParcelas()}" value="Confirma" reRender="mensagemPanelModalAjusteParcela,parcelasCEFDataTable" styleClass="name2-1" >
				                <rich:componentControl for="panelModalAjusteParcela" attachTo="btConfirmaAjusteParcelaCEFModal" operation="hide" event="onclick"/>
							</a:commandButton>
							
							<a:commandButton id="btCancelaAjusteParcelaCEFModal" value="Cancelar" styleClass="name2">
				                <rich:componentControl for="panelModalAjusteParcela" attachTo="btCancelaAjusteParcelaCEFModal" operation="hide" event="onclick"/>
							</a:commandButton>
							
							
						</h:panelGrid>
	        </a:form>
	        
	        
	    </rich:modalPanel>
	    
	    <!-- Modal de quitar parcela -->	
	    <rich:modalPanel id="panelModalQuitaParcela" width="360" height="170">
	        <f:facet name="header">
	            <h:panelGroup>
	                <h:outputText value="Quitar Parcela"></h:outputText>
	            </h:panelGroup>
	        </f:facet>
	        <f:facet name="controls">
	            <h:panelGroup>
	                <h:graphicImage value="/img/close.png" styleClass="hidelink" id="hidelink2"/>
	                <rich:componentControl for="panelModalQuitaParcela" attachTo="hidelink2" operation="hide" event="onclick"/>
	            </h:panelGroup>
	        </f:facet>
	        
	        <s:div id="mensagemPanelModalQuitaParcela">
		        <h:messages />
	        </s:div>
	        <a:form>
						<h:panelGrid width="100%" columns="2" border="0" >
						
							<h:outputText value="Parcela" styleClass="name2" />
							<h:outputText id="parcelaID2" value="#{ConsultaVenda.parcelaFinancimentoCEFSelecionada.parcela}a" />
							
							<h:outputText value="Vencimento" styleClass="name2" />
							<h:outputText id="vencimentoID2" value="#{ConsultaVenda.parcelaFinancimentoCEFSelecionada.dataVencimento}" />
							
							<h:outputText value="Situacao" styleClass="name2" />
							<h:outputText id="situacaoID2" value="#{ConsultaVenda.parcelaFinancimentoCEFSelecionada.statusParcela}" />

							<h:outputText value="Valor Atual" styleClass="name2" />
							<h:outputText id="valorAtualID2" value="#{ConsultaVenda.parcelaFinancimentoCEFSelecionada.valor}" />
							
						</h:panelGrid>
						
						<rich:spacer />
						<h:panelGrid width="100%" columns="2" border="0" style="align: center" >
							
							<a:commandButton id="btConfirmaQuitaParcelaCEFModal" action="#{ConsultaVenda.quitaParcelaCEF()}" value="Confirma" reRender="mensagemPanelModalQuitaParcela,parcelasCEFDataTable" styleClass="name2-1" >
				                <rich:componentControl for="panelModalQuitaParcela" attachTo="btConfirmaQuitaParcelaCEFModal" operation="hide" event="onclick"/>
							</a:commandButton>
							
							<a:commandButton id="btCancelaQuitaParcelaCEFModal" value="Cancelar" styleClass="name2">
				                <rich:componentControl for="panelModalQuitaParcela" attachTo="btCancelaQuitaParcelaCEFModal" operation="hide" event="onclick"/>
							</a:commandButton>
							
							
						</h:panelGrid>
	        </a:form>
	        
	        
	    </rich:modalPanel>		
		

</ui:define>

</ui:composition>
